package org.lee.export;

import org.lee.export.model.ApiResult;
import org.lee.export.model.ResultCode;
import org.lee.export.model.SourceType;
import org.lee.merge.IImageMerger;
import org.lee.merge.impl.DefaultImageMergeStrategy;
import org.lee.merge.impl.ImageMerger;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * @author jackielee
 * @version 1.0
 * @description App
 * @date 2021/5/6
 **/
public class App {
    public static void main3(String[] args) {
        IPptExporter exporter = new PptExportProxyService();
        System.out.println("please input the ppt files path:");
        String pptPath = new Scanner(System.in).nextLine();
        String pathSave = pptPath + File.separator + "out";
        System.out.println("save to the path:" + pathSave);
        ApiResult result = exporter.export(pptPath, pathSave, SourceType.DIR);
        if (result.getCode() != ResultCode.SUCCESS.getCode()) {
            System.out.println(result.getMessage());
            return;
        }
        Map<String, List<String>> data = result.getData();
        for (Map.Entry<String, List<String>> item : data.entrySet()) {
            System.out.println("the file " + item.getKey() + " export for :" + String.join(",", item.getValue()));
        }
        System.out.println("end.");
    }

    public static void main2(String[] args) {
        IPptExporter exporter = new PptExportProxyService();
        System.out.println("please input the ppt file:");
        String pptPath = new Scanner(System.in).nextLine();
        File file = new File(pptPath);
        String pathSave = file.getParent() + File.separator + "out";
        System.out.println("save to the path:" + pathSave);
        ApiResult result = exporter.export(pptPath, pathSave);
        if (result.getCode() != ResultCode.SUCCESS.getCode()) {
            System.out.println(result.getMessage());
            return;
        }
        Map<String, List<String>> data = result.getData();
        for (Map.Entry<String, List<String>> item : data.entrySet()) {
            System.out.println("the file " + item.getKey() + " export for :" + String.join(",", item.getValue()));
        }
        System.out.println("end.");
    }

    public static void main(String[] args) {
        IImageMerger imageMerger = new ImageMerger(new DefaultImageMergeStrategy());
        System.out.println("please input the image files path:");
        String imgPath = new Scanner(System.in).nextLine();
        String fileName = imgPath + File.separator + "merge-result.png";
        System.out.println("save to:" + fileName);
        ApiResult result = imageMerger.merge(imgPath, fileName);
        if (result.getCode() != ResultCode.SUCCESS.getCode()) {
            System.out.println(result.getMessage());
            return;
        }
        System.out.println("end.");
    }

    public static void main4(String[] args) {
        System.out.println("please input the image files path:");
        String imgPath = new Scanner(System.in).nextLine();
        try {
            new DefaultImageMergeStrategy().draw(imgPath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("end.");
    }
}
